package com.nineclock.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nineclock.system.pojo.SysCompanyUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@Mapper
public interface SysCompanyUserMapper extends BaseMapper<SysCompanyUser> {

    @Select("SELECT * FROM nineclock_sys.sys_company_user \n" +
            "WHERE id=(SELECT company_user_id FROM nineclock_sys.sys_company_user_role \n" +
            "WHERE role_id=(SELECT id FROM nineclock_sys.sys_role \n" +
            "WHERE company_id=#{companyId} \n" +
            "AND role_name='ROLE_ADMIN_SYS') \n" +
            "AND company_id=#{companyId})\n" +
            "AND company_id=#{companyId}")
    public SysCompanyUser queryMainAdminCompanyUser(@Param("companyId") Long companyId);
}
